<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2022-12-17 16:02:46
 * @Last Modified time: 2022-12-19 17:51:14
 */
namespace app\common\services\store;

use app\common\dao\store\GoodsLabelDao;

use frank\base\BaseService;
use frank\exception\CommonException;
use frank\utils\helper\ArrayHelper;

/**
 * Class GoodsLabelService
 */
class GoodsLabelService extends BaseService
{

    /**
     * GoodsLabelService constructor.
     * @param GoodsLabelDao $dao
     */
    public function __construct(GoodsLabelDao $dao)
    {
        $this->dao = $dao;
    }

    public function getGoodsLabelDetail($filter)
    {
        $detail = $this->dao->detail($filter);
        if (!$detail) {
            throw new CommonException('数据不存在');
        }
        return $detail->toArray();
    }

    /**
     * 获取列表
     */
    public function getGoodsLabelList(array $params)
    {
        [$page, $limit] = $this->getPageValue();
        $where = [];
        if(!empty($params['group_id']) && $params['group_id'] != -1){
            $where['group_id'] = $params['group_id'];
        }
        $list = $this->dao->getGoodsLabelList($where, $page, $limit);
        return $list;
    }
    /**
     * 获取列表
     */
    public function getGoodsLabelSelect()
    {
        $list = $this->dao->getGoodsLabelSelect();
        return $list;
    }

}
